<template>
  <div class="feedback">
    <div style="height: 88px;"></div>

    <Header></Header>
    <div class="feedback-box">
      <p class="title">{{ $t('assemble.意见反馈') }}</p>
      <div class="feedback-content" style="font-size: 14px;">
        <p>{{ $t('assemble.反馈内容意见') }}</p>
        <el-input type="textarea" :placeholder="$t('assemble.请输入')" v-model="content" maxlength="300" show-word-limit>
        </el-input>
        <p>{{ $t('assemble.图片选填提供问题截图') }}</p>
        <div class="img-box">
          <el-upload action="https://demo163.1p5.net/index.php/api/common/upload" list-type="picture-card"
            :on-preview="handlePictureCardPreview" :on-remove="handleRemove" :headers="headers" :on-success="submit">
            <i class="el-icon-plus"></i>
          </el-upload>
          <el-dialog :visible.sync="dialogVisible">
            <img width="100%" :src="dialogImageUrl" alt="">
          </el-dialog>
        </div>
        <p>{{ $t('assemble.联系人') }}</p>
        <el-input v-model="linkman" :placeholder="$t('assemble.请输入')"></el-input>
        <p>{{ $t('assemble.联系方式') }}</p>
        <el-input v-model="contactway" :placeholder="$t('assemble.请输入')"></el-input>
        <div class="login-btn" @click="submitfeedBack">{{ $t('assemble.提交') }}</div>
      </div>
    </div>
    <div style="height: 254px;"></div>
    <Footer></Footer>
  </div>
</template>
<script>
import Header from '@/components/header/index.vue'
import Footer from '@/components/footer/index.vue';
import { feedback } from "../../utils/api"
export default {
  components: {
    Header,
    Footer
  },
  data() {
    return {
      content: '',//内容
      linkman: '',//联系人
      contactway: '', //联系方式
      dialogImageUrl: '',
      dialogVisible: false,
      imgs: '',
      headers: {}
    }
  },
  mounted() {
    let obj = {
      token: localStorage.getItem('token')
    }
    this.headers = obj
  },
  methods: {
    handleRemove(file, fileList) {
      console.log(file, fileList);
    },
    handlePictureCardPreview(file, fileList) {
      console.log(file, "file", fileList)
      this.dialogImageUrl = file.url;
      this.dialogVisible = true;

    },
    submit(res, img, fileList) {
      console.log(res, "eee")
      this.imgs = this.imgs + res.data.url + ","
    },
    async submitfeedBack() {
      let data = {
        content: this.content,
        name: this.linkman,
        mobile: this.contactway,
        images: this.imgs
      }
      console.log("data", data)
      let res = await feedback(data)
      if (res.code == 1) {
        this.$message({
          message: this.$t('assemble.反馈成功'),
          type: 'success'
        });
        setTimeout(() => {
          location.reload()

        }, 1500);
      } else {
        this.$message({
          message: res.msg,
          type: 'success'
        });

      }
      if (res.code == 401) {
        this.$router.push({ path: '/login' })
      }
    },


  }
}
</script>
<style scoped lang="scss">
.feedback {
  display: flex;
  flex-direction: column;
  align-items: center;

  .feedback-box {
    width: 1000px;
    overflow-y: auto;

    .title {
      font-size: 15px;
      font-family: PingFang SC-Medium, PingFang SC;
      font-weight: 500;
      color: #333333;
      line-height: 23px;
      width: 100%;
      text-align: center;
    }

    .img-box {
      width: 99%;
      border-radius: 10px 10px 10px 10px;
      opacity: 1;
      border: 1px solid #B1B1B1;
      padding: 10px;
      box-sizing: border-box;

      img {
        width: 80px;
        height: 80px;
        cursor: pointer;
      }
    }

    .login-btn {
      width: 350px;
      height: 45px;
      background: linear-gradient(315deg, #E00000 0%, #FF2424 100%);
      border-radius: 22px 22px 22px 22px;
      opacity: 1;
      font-size: 18px;
      font-family: PingFang SC-Regular, PingFang SC;
      font-weight: 400;
      color: #FFFFFF;
      line-height: 45px;
      text-align: center;
      margin: 50px auto 0;
      cursor: pointer;

    }

  }
}
</style>